<template>
    <div>
        <el-table :data="tableData" stripe style="width: 100%">
            <el-table-column type="index" label="#" width="70">
            </el-table-column>
            <el-table-column prop="authName" label="权限名称">
            </el-table-column>
            <el-table-column prop="path" label="路径">
            </el-table-column>
            <el-table-column prop="level" label="权限等级">
                <template slot-scope="scope">
                    <el-tag :type="`${scope.row.level == 0 ? '' : scope.row.level == 1 ? 'success' : 'warning'}`">{{
                        scope.row.level == 0 ? '一级' : scope.row.level == 1 ? '二级' : '三级'
                    }}</el-tag>
                </template>
            </el-table-column>
        </el-table>
        <!-- 分页 -->
        <div class="block">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagenum"
                :page-sizes="[5, 10, 15, 20]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper"
                :total="total">
            </el-pagination>
        </div>
    </div>
</template>
<script>
import { getRights } from '../untils/api'
export default {
    data() {
        return {
            tableData: [],
            total: 0,
            pagenum: 1,
            pagesize: 5
        }
    },
    methods: {
        //分页
        handleSizeChange(val) {
            this.pagesize = val
            this.page()
           
            // console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
            this.pagenum = val
            this.page()
          
            // console.log(`当前页: ${val}`);
        },
        page() {
            getRights().then(res => {
                // console.log(res);
                this.total=res.data.data.length
                this.tableData = res.data.data.slice((this.pagenum - 1) * this.pagesize, this.pagenum * this.pagesize)
            })
        }
    },
    created() {
      this.page()
    }
}
</script>
<style lang="scss" scoped></style>


